<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>商品更新 - 绿色农业后台管理系统</title>
  <link rel="icon" href="favicon.ico" type="image/ico">
  <meta name="keywords" content="ZZMLY,后台管理系统">
  <meta name="description" content="ZZMLY是一个基于Bootstrap 的后台管理系统">
  <meta name="author" content="yinqi">
  <link th:href="@{BMS/css/bootstrap.min.css}" rel="stylesheet">
  <link th:href="@{BMS/css/materialdesignicons.min.css}" rel="stylesheet">
  <link th:href="@{BMS/css/style.min.css}" rel="stylesheet">
</head>

<body>
<main class="lyear-layout-content">

  <div class="container-fluid">

    <div class="row">
      <div class="col-lg-12">
        <div class="card">
          <div class="card-body">
            <input th:value="${session.admininfor.adminName}" type="hidden">

            <form action="PostAupdatePuduct" method="post" class="row">
              <div class="form-group col-md-12">
                <label>商品图片</label>
                <div class="form-controls">

                  <input name="productImage" th:value="${productsinfor.productImage}" type="hidden"  id="file">

                  <ul class="list-inline clearfix lyear-uploads-pic">
                    <li class="col-xs-4 col-sm-3 col-md-2">
                      <figure>
                        <img th:src="${productsinfor.productImage}" alt="图片" id="img">
<!--                        <figcaption>-->
<!--                          <a class="btn btn-round btn-square btn-primary" href="#!"><i class="mdi mdi-eye"></i></a>-->
<!--                          <a class="btn btn-round btn-square btn-danger" href="#!"><i class="mdi mdi-delete"></i></a>-->
<!--                        </figcaption>-->
                      </figure>
                    </li>
                    <li class="col-xs-4 col-sm-3 col-md-2">

                      <input  type="hidden" title="点击上传" id="imagesFile" >

                      <!--                          <a class="pic-add" id="add-pic-btn" href="#!" ></a>-->
                    </li>
                  </ul>
                </div>
              </div>

              <div class="form-group col-md-12">
                <label>商品图片</label>
                <div class="form-controls">
                  <div class="form-group col-md-12">
                    <label>是否上传</label>
                    <div class="clearfix">
                      <label class="lyear-radio radio-inline radio-primary">
                        <input type="radio" name="productState" value="已上传"><span>已上传</span>
                      </label>
                      <label class="lyear-radio radio-inline radio-primary">
                        <input type="radio" name="productState" value="未上传" checked><span>未上传</span>
                      </label>
                    </div>
                  </div>
                </div>
              </div>

              <div class="form-group col-md-12">
                <input type="hidden" th:value="${productsinfor.productId}" id="productId" name="productId">
                <label for="productReleaseTime">商品上架日期</label>
                <input type="datetime-local" class="form-control" id="productReleaseTime" name="productReleaseTime" th:value="${productsinfor.productReleaseTime}" />
              </div>


                <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确定更新</button>
                <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>

            </form>

          </div>
        </div>
      </div>

    </div>

  </div>

</main>



<script type="text/javascript" th:src="@{BMS/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{BMS/js/bootstrap.min.js}"></script>
<!--<script type="text/javascript" th:src="@{BMS/js/perfect-scrollbar.min.js}"></script>-->
<!--<script type="text/javascript" th:src="@{BMS/js/main.min.js}"></script>-->
<script type="text/javascript">
$(function(){
    $('.search-bar .dropdown-menu a').click(function() {
        var field = $(this).data('field') || '';
        $('#search-field').val(field);
        $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });
});
  $(function (){
    var btn = $('#imagesFile');
    console.log(btn)
    btn.change(function (){
      var file = btn[0].files[0]
      var data = new FormData();
      data.append('file',file);
      console.log(data)
      $.ajax({
        url:'/upFile',
        type:'post',
        data:data,
        processData:false,
        contentType:false,
        success:function (response){
          console.log(response)
          $("#file").attr("value",response)
          $("#img").attr("src",response)
        }
      })
    })
  })
</script>

</body>
</html>